CC=gcc
LIBS=
CFLAGS=-O2 -Wall -fPIC
INCLUDEPATH=-I. 
LDFLAGS= -shared
#OUTPUT_DIR=out
OUTPUT_NAME=libtwofish.so
TEST_NAME=test
OBJECTS=expandkey.o field.o h_func.o matrix.o mul_tab.o pht.o \
	q_perm.o rotate.o tables.o twofish.o set_error_insert.o error_insert_help.o
$(OUTPUT_NAME) : $(OBJECTS) $(OUTPUT_NAME_E)
	$(CC) -o $(OUTPUT_NAME) $(LIBS) $(LDFLAGS) $(OBJECTS)
#mkdir : $(OUTPUT_DIR)
#	mkdir $(OUTPUT_DIR)
expandkey.o : expandkey.c expandkey.h types.h h_func.h matrix.h field.h\
	tables.h mul_tab.h pht.h rotate.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o expandkey.o -c expandkey.c
field.o : field.c types.h field.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o field.o -c field.c
h_func.o : h_func.c h_func.h types.h q_perm.h matrix.h tables.h mul_tab.h\
	field.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o h_func.o -c h_func.c
matrix.o : matrix.c types.h matrix.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o matrix.o -c matrix.c
mul_tab.o : mul_tab.c mul_tab.h types.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o mul_tab.o -c mul_tab.c
pht.o : pht.c types.h pht.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o pht.o -c pht.c
q_perm.o : q_perm.c types.h q_perm.h tables.h rotate.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o q_perm.o -c q_perm.c
rotate.o : rotate.c types.h rotate.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o rotate.o -c rotate.c
tables.o : tables.c types.h tables.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o tables.o -c tables.c
twofish.o : twofish.c types.h twofish.h h_func.h matrix.h tables.h \
	mul_tab.h field.h pht.h rotate.h set_error_insert.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o twofish.o -c twofish.c
set_error_insert.o : set_error_insert.c types.h set_error_insert.h
	$(CC) $(INCLUDEPATH) $(CFLAGS) -c set_error_insert.c
error_insert_help.o : error_insert_help.c types.h error_insert_help.h
	$(CC) $(INCLUDEPATH) $(CFLGAS) -c error_insert_help.c
$(TEST_NAME) : $(OUTPUT_NAME) test_main.c
	$(CC) $(INCLUDEPATH) $(CFLAGS) -o $(TEST_NAME) $(OUTPUT_NAME) test_main.c
clean : 
	-rm $(OBJECTS) $(OUTPUT_NAME) 
